/**
 * 
 */
package cn.yuemouren.security.core.authentication;

import cn.yuemouren.security.core.properties.SecurityConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;


/**
 * @Author: Timi
 * @Description: 公用配置
 * @Date: 2020/6/20 17:35
 * @Version: v1.0
 */
public class AbstractChannelSecurityConfig extends WebSecurityConfigurerAdapter {

	@Autowired
	protected AuthenticationSuccessHandler timiAuthenticationSuccessHandler;
	
	@Autowired
	protected AuthenticationFailureHandler timiAuthenticationFailureHandler;
	
	protected void applyPasswordAuthenticationConfig(HttpSecurity http) throws Exception {
		http.formLogin()
				//登录页面
				.loginPage(SecurityConstants.DEFAULT_UNAUTHENTICATION_URL)
				//登录请求url
				.loginProcessingUrl(SecurityConstants.DEFAULT_LOGIN_PROCESSING_URL_FORM)
				//指定成功处理器
				.successHandler(timiAuthenticationSuccessHandler)
				//指定失败处理器
				.failureHandler(timiAuthenticationFailureHandler);
	}
	
}
